package cn.tedu.device.controller;

import cn.tedu.device.service.GunService;
import cn.tedu.micro.demo.common.pojo.po.GunInfoPO;
import cn.tedu.micro.demo.common.pojo.protocol.JsonResult;
import cn.tedu.micro.demo.common.pojo.vo.GunInfoVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GunController {
    @Autowired
    private GunService gunService;

    @GetMapping("/device/gun/info/{gunId}")
    public JsonResult<GunInfoVO> getGunInfo(Integer gunId) {
        GunInfoPO gunInfoPO = gunService.getDetail(gunId);
        if (gunInfoPO == null){
            return JsonResult.ok("没有此枪的信息",null);
        }
        GunInfoVO gunInfoVO = new GunInfoVO();
        BeanUtils.copyProperties(gunInfoPO,gunInfoVO);
        return JsonResult.ok("ok",gunInfoVO);
    }
}
